package com.hjm.ui.order.entity;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;

public class Order implements Parcelable {
    private Integer orderId;
    private Integer goodsId;
    private String goodsName;
    private Integer goodsIconId;
    private String goodsType;
    private int goodsNum;
    private BigDecimal price;
    @JSONField(serialize = false)
    private Bitmap goodsIcon;

    public Order() {
    }

    protected Order(Parcel in) {
        if (in.readByte() == 0) {
            orderId = null;
        } else {
            orderId = in.readInt();
        }
        if (in.readByte() == 0) {
            goodsId = null;
        } else {
            goodsId = in.readInt();
        }
        goodsName = in.readString();
        if (in.readByte() == 0) {
            goodsIconId = null;
        } else {
            goodsIconId = in.readInt();
        }
        goodsType = in.readString();
        goodsNum = in.readInt();
        goodsIcon = in.readParcelable(Bitmap.class.getClassLoader());
    }

    public static final Creator<Order> CREATOR = new Creator<Order>() {
        @Override
        public Order createFromParcel(Parcel in) {
            return new Order(in);
        }

        @Override
        public Order[] newArray(int size) {
            return new Order[size];
        }
    };

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public Integer getGoodsIconId() {
        return goodsIconId;
    }

    public void setGoodsIconId(Integer goodsIconId) {
        this.goodsIconId = goodsIconId;
    }

    public String getGoodsType() {
        return goodsType;
    }

    public void setGoodsType(String goodsType) {
        this.goodsType = goodsType;
    }

    public int getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(int goodsNum) {
        this.goodsNum = goodsNum;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + orderId +
                ", goodsId=" + goodsId +
                ", goodsName='" + goodsName + '\'' +
                ", goodsIconId=" + goodsIconId +
                ", goodsType='" + goodsType + '\'' +
                ", goodsNum=" + goodsNum +
                ", price=" + price +
                ", goodsIcon=" + goodsIcon +
                '}';
    }

    public Bitmap getGoodsIcon() {
        return goodsIcon;
    }

    public void setGoodsIcon(Bitmap goodsIcon) {
        this.goodsIcon = goodsIcon;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(this.goodsName);
        dest.writeInt(this.goodsIconId);
        dest.writeString(this.goodsType);
        dest.writeInt(this.goodsNum);
        dest.writeSerializable(this.price);
        dest.writeParcelable(this.goodsIcon, flags);
        dest.writeValue(this.orderId);
        dest.writeValue(this.goodsId);
    }
}
